package com.demo.controller;

import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImageFormats;
import org.apache.commons.imaging.ImagingException;

import java.io.File;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class WriteImageExample {
    public static void main(String[] args) {
        try {
            File inputFile = new File("/Users/wangfengchen/Downloads/test/1.png");
            BufferedImage image = Imaging.getBufferedImage(inputFile);

            // 在这里可以对image进行各种处理...

            File outputFile = new File("/Users/wangfengchen/Downloads/test/success.png");
            Imaging.writeImage(image, outputFile, ImageFormats.PNG, null);
            System.out.println("图像保存成功！");
        } catch (ImagingException | IOException e) {
            e.printStackTrace();
        }
    }
}
